import { log } from "console";
import { GameModel } from "../../model/game";

import{ get, set, del, client } from "../../redis"

// {
//     DM_nickname: "牛小排",
//     DM_id: 1,
//     scriptName:"第一天",
//     scriptId: 1,
//     role: {},
//     isOver:false,
//     is_deleted: false
// }

class _GameService {
    async insertGame(game:any) {
        console.log("game",[game]);
        try{
            let _game = {
                DM_nickname:"牛小排22",
                DM_id:100,
                scriptName:"第一天22",
                scriptId:100,
                role:JSON.stringify({}),
                isOver:false,
                is_deleted: false
        }
        const res = await GameModel.bulkCreate([game]);
        console.log("res", res);
        
        return res
        } catch(err) {
            console.log("err", err);
            
        }
    }

    async getGameInfo(gameId:any) {
        console.log("game", gameId);
        
        const res = await GameModel.findOne({
            where:{id:gameId}
        })
       console.log("找game", res);
       

        return res
    }

    async updateGame(id:number,options:any) {
        const res = await GameModel.update(options, {
            where: {
              id
            }
          })
    }


}

const GameService = new _GameService();

export {
    GameService
}